import { Component, OnInit, ChangeDetectorRef, ViewChild } from '@angular/core';
import { HomepagePopAddComponent } from './homepage-pop-add/homepage-pop-add.component';
import { HomepagePopGridComponent } from './homepage-pop-grid/homepage-pop-grid.component';
import { masterService } from '../../../../lib/master.service';
import { path } from '../../../path.config';

@Component({
    selector: 'app-homepage-popup',
    templateUrl: './homepage-popup.component.html',
    styleUrls: ['./homepage-popup.component.css']
})
export class HomepagePopupComponent implements OnInit {
    @ViewChild('homePageAdd') public homePageAdd: HomepagePopAddComponent;
    @ViewChild('homePageGrid') private homePageGrid: HomepagePopGridComponent;

    private getList = path.pageManagement.homepagePopup.getHomePageList;

    ngOnInit() { }

    openModal() {
        this.homePageAdd.newHomepage.show();
    }

    public filter: any = {
        pageName: '',
        pageSize: '10',
        pageIndex: '1'
    }

    constructor(private _masterService: masterService,
                private cdRef: ChangeDetectorRef) { }

    // 筛选首页弹窗列表
    public selectListItem() {
        this.homePageGrid.onChangeTable(this.filter, '1');
    }

    // 新建确认后触发
    homePageAddFunc() {
        this.homePageGrid.onChangeTable(this.filter, '1');
    }
}
